package com.net.collection;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeSet;


class Test implements Comparable<Test>
{
	private String name;
	private int age;
	
	
	
	
	public String getName() {
		return name;
	}



	public void setName(String name) {
		this.name = name;
	}



	public int getAge() {
		return age;
	}



	public void setAge(int age) {
		this.age = age;
	}



	Test(String name, int age)
	{
		this.name = name;
		this.age  = age;
	}
	

	
	@Override
	public String toString() 
	{
		
		return name + "  " +age;
	}



	@Override
	public int compareTo(Test test) 
	{
		
		return this.age-test.age;
	}
	
}





public abstract class TestDemo {

	public static void main(String[] args)
	{
		TreeSet<Test> sets = new TreeSet<>();
		
		Test t1 = new Test("dinesh",55);
		Test t2 = new Test("sadesh", 13);
		
		
		sets.add(t1);
		sets.add(t2);
		
		
		for(Test t : sets)
		{
			System.out.println(t.getAge() + "   " +t.getName());
		}
		
		
		
		
		

	}

}
